/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.oim.test.ui.component;

import java.util.ArrayList;
import java.util.List;

import com.oim.core.common.data.FaceData;
import com.oim.core.config.FaceConfig;
import com.oim.fx.common.box.ImageBox;
import com.oim.fx.ui.BaseFrame;
import com.oim.fx.ui.chat.FacePopup;
import com.oim.fx.ui.component.ImageStyleButton;
import com.only.fx.OnlyPopupOver;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.layout.VBox;

/**
 *
 * @author XiaHui
 */
public class FaceFrame extends BaseFrame {

	VBox rootVBox = new VBox();

	VBox topBox = new VBox();
	VBox centerBox = new VBox();
	VBox bottomBox = new VBox();

	OnlyPopupOver po = new OnlyPopupOver();
	Button button = new Button("弹出");
	FacePopup facePopup = new FacePopup();
	FaceConfig faceConfig = new FaceConfig();

	public FaceFrame() {
		init();
		initEvent();
	}

	private void init() {
		this.setTitle("测试");
		this.setWidth(380);
		this.setHeight(300);
		this.setRadius(10);
		this.setCenter(rootVBox);

		topBox.setPrefHeight(28);

		rootVBox.setStyle("-fx-background-color:rgba(255, 255, 255, 1)");
		rootVBox.getChildren().add(topBox);
		rootVBox.getChildren().add(centerBox);
		rootVBox.getChildren().add(bottomBox);

		centerBox.getChildren().add(button);
		List<FaceData> list = faceConfig.createFaceList();
		facePopup.set("classical", "经典", list);
		list = faceConfig.emotionList();
		facePopup.set("emotion", "经典", list);
	}

	private void initEvent() {
		button.setOnAction(new EventHandler<ActionEvent>() {

			@Override
			public void handle(ActionEvent event) {
				// po.show(button4,1d,2d);
				facePopup.show(button);

			}
		});
	}

	public List<ImageStyleButton> createList() {
		List<ImageStyleButton> list = new ArrayList<ImageStyleButton>();
		Image normalImage;
		Image hoverImage;

		ImageStyleButton iconButton;

		String normal = " ";
		String selected = " ";
		for (int i = 0; i < 214; i++) {
			normal = "Resources/Images/Face/png/" + i + ".png ";
			selected = "Resources/Images/Face/" + i + ".gif ";
			normalImage = ImageBox.getImagePath(normal);
			hoverImage = ImageBox.getImagePath(selected);

			ImageStyleButton ib = new ImageStyleButton(normalImage, hoverImage, null);
			ib.setPrefSize(40, 40);
			ib.setMinSize(40, 40);
			list.add(ib);
		}

		for (int i = 1000; i < 1003; i++) {
			normal = "Resources/Images/Face/OperationPath/" + i + ".png ";
			selected = "Resources/Images/Face/OperationPath/" + i + ".gif ";
			normalImage = ImageBox.getImagePath(normal);
			hoverImage = ImageBox.getImagePath(selected);

			iconButton = new ImageStyleButton(normalImage, hoverImage, null);
			iconButton.setPrefSize(40, 40);
			iconButton.setMinSize(40, 40);
			list.add(iconButton);
		}

		normal = "Resources/Images/Face/OperationPath/" + 1014 + ".png ";
		selected = "Resources/Images/Face/OperationPath/" + 1014 + ".gif ";
		normalImage = ImageBox.getImagePath(normal);
		hoverImage = ImageBox.getImagePath(selected);

		iconButton = new ImageStyleButton(normalImage, hoverImage, null);
		iconButton.setPrefSize(40, 40);
		iconButton.setMinSize(40, 40);
		list.add(iconButton);

		normal = "Resources/Images/Face/OperationPath/" + 1017 + ".png ";
		selected = "Resources/Images/Face/OperationPath/" + 1017 + ".gif ";
		normalImage = ImageBox.getImagePath(normal);
		hoverImage = ImageBox.getImagePath(selected);

		iconButton = new ImageStyleButton(normalImage, hoverImage, null);
		iconButton.setPrefSize(40, 40);
		iconButton.setMinSize(40, 40);
		list.add(iconButton);

		normal = "Resources/Images/Face/OperationPath/" + 1022 + ".png ";
		selected = "Resources/Images/Face/OperationPath/" + 1022 + ".gif ";
		normalImage = ImageBox.getImagePath(normal);
		hoverImage = ImageBox.getImagePath(selected);

		iconButton = new ImageStyleButton(normalImage, hoverImage, null);
		iconButton.setPrefSize(40, 40);
		iconButton.setMinSize(40, 40);
		list.add(iconButton);

		normal = "Resources/Images/Face/OperationPath/" + 1024 + ".png ";
		selected = "Resources/Images/Face/OperationPath/" + 1024 + ".gif ";
		normalImage = ImageBox.getImagePath(normal);
		hoverImage = ImageBox.getImagePath(selected);

		iconButton = new ImageStyleButton(normalImage, hoverImage, null);
		iconButton.setPrefSize(40, 40);
		iconButton.setMinSize(40, 40);
		list.add(iconButton);

		for (int i = 1027; i < 1031; i++) {
			normal = "Resources/Images/Face/OperationPath/" + i + ".png ";
			selected = "Resources/Images/Face/OperationPath/" + i + ".gif ";
			normalImage = ImageBox.getImagePath(normal);
			hoverImage = ImageBox.getImagePath(selected);

			iconButton = new ImageStyleButton(normalImage, hoverImage, null);
			iconButton.setPrefSize(40, 40);
			iconButton.setMinSize(40, 40);
			list.add(iconButton);
		}

		normal = "Resources/Images/Face/OperationPath/" + 1034 + ".png ";
		selected = "Resources/Images/Face/OperationPath/" + 1034 + ".gif ";
		normalImage = ImageBox.getImagePath(normal);
		hoverImage = ImageBox.getImagePath(selected);

		iconButton = new ImageStyleButton(normalImage, hoverImage, null);
		iconButton.setPrefSize(40, 40);
		iconButton.setMinSize(40, 40);
		list.add(iconButton);

		normal = "Resources/Images/Face/OperationPath/" + 1040 + ".png ";
		selected = "Resources/Images/Face/OperationPath/" + 1040 + ".gif ";
		normalImage = ImageBox.getImagePath(normal);
		hoverImage = ImageBox.getImagePath(selected);

		iconButton = new ImageStyleButton(normalImage, hoverImage, null);
		iconButton.setPrefSize(40, 40);
		iconButton.setMinSize(40, 40);
		list.add(iconButton);

		normal = "Resources/Images/Face/OperationPath/" + 1042 + ".png ";
		selected = "Resources/Images/Face/OperationPath/" + 1042 + ".gif ";
		normalImage = ImageBox.getImagePath(normal);
		hoverImage = ImageBox.getImagePath(selected);

		iconButton = new ImageStyleButton(normalImage, hoverImage, null);
		iconButton.setPrefSize(40, 40);
		iconButton.setMinSize(40, 40);
		list.add(iconButton);

		for (int i = 1070; i < 1075; i++) {
			normal = "Resources/Images/Face/OperationPath/" + i + ".png ";
			selected = "Resources/Images/Face/OperationPath/" + i + ".gif ";
			normalImage = ImageBox.getImagePath(normal);
			hoverImage = ImageBox.getImagePath(selected);

			iconButton = new ImageStyleButton(normalImage, hoverImage, null);
			list.add(iconButton);
		}
		return list;
	}
}
